﻿using ModuleBase;
using ModuleBase.googoltech.GTS;
using Newtonsoft.Json.Linq;
using Prism.Ioc;

namespace GetDi
{
    public class GetDi : ModuleBase.ModuleBase
    {
        private int cardNo = 0;
        public int CardNo
        {
            get { return cardNo; }
            set { cardNo = value; }
        }
        private int dINo;
        public int DINo
        {
            get { return dINo; }
            set { dINo = value; }
        }
        public override Dictionary<string, object> GetProperties()
        {
            return new Dictionary<string, object>()
            {
                { "卡号",CardNo},
                { "DI",DINo}
            };
        }

        public override bool Execute()
        {
            bool keyValuePairs = GTSCard.GetDi((short)CardNo, (ushort)DINo);
            return keyValuePairs;
        }

        public override async Task<bool> ExecuteAsync()
        {
            var result = await Task.Run(() => Execute());
            return result;
        }

        public override void Initialize()
        {

        }
        //写构造函数
        public GetDi()
        {
            Name = "GetDi"; 
            DisplayNameToPropertyNameMap = new Dictionary<string, string>
            {
                { "卡号", nameof(CardNo) },
                { "DI", nameof(DINo) },
            };
        }

        public override string Description => "DI信号获取模块：用于读取指定轴卡的数字输入（DI）信号状态。";
    }
}
